package panel.setPanel
{
	import assists.HtmlText;
	import assists.Scale9Grid;
	import assists.TextFieldUtils;
	import assists.resource.ResourceLoader;
	
	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.text.TextField;
	
	import main.ClientConstants;
	import main.LocalStoreInfo;
	
	public class PicSetItem extends Sprite
	{
		private var _label:TextField = new TextField();
		private var _slideBtn:SlideBtn;
		private var _stage:Stage;
		private var _loader:ResourceLoader;
		private var _localStore:LocalStoreInfo = new LocalStoreInfo();
		public function PicSetItem(stage:Stage,loader:ResourceLoader)
		{
			_stage = stage;
			_loader = loader;
			
			init();
		}
		
		private function init():void
		{
			var picCallBack:Function = function (data:int):void
			{
				_localStore.storeInfo("loadPic",{value:data});
				ClientConstants.NET_MODE = data;
			}
			
			_slideBtn = new SlideBtn(_loader);
			if(_localStore.readInfo("loadPic") == null)
			{
				_localStore.storeInfo("loadPic",{value:ClientConstants.PIC_LOAD_YES})
				_slideBtn.show(true,picCallBack);
			}else
			{
				if(_localStore.readInfo("loadPic").value == ClientConstants.PIC_LOAD_NO)
				{
					_slideBtn.show(false,picCallBack);
				}else
				{
					_slideBtn.show(true,picCallBack);
				}
				
			}
			
			
			
			_label.mouseEnabled = false;
			_label.autoSize = "left";
			
			TextFieldUtils.setHtmlText(_label,HtmlText.format("是否下载图片资源:",0,20));
			
			var backGround:Bitmap = _loader.uiManager.generateBmp(_loader.uiManager.weatherBack,true);
			backGround.height = _stage.stageHeight * 0.2;
			backGround.width = _stage.stageWidth * 0.9;
			backGround.x = _stage.stageWidth * 0.05;
			
			
			_slideBtn.x = _stage.stageWidth - _stage.stageWidth * 0.1 - _slideBtn.width;
			_slideBtn.y = (backGround.height - _slideBtn.height) * 0.5;
			
			_label.x = _stage.stageWidth * 0.05;
			_label.y = (backGround.height - _label.height) * 0.5;
			
			
			this.addChild(backGround);
			this.addChild(_label);
			this.addChild(_slideBtn);
		}
		
	}
}